#!/usr/bin/env python3
# -*- Coding:UTF-8 -*-
#  11:08


import requests
from tools.json_tool import JsonTool

# method='POST'
# url='http://localhost:8080/WoniuSales-20180508-V1.4-bin/user/login'


class LoginApi(object):
    def __init__(self,session):         #会话对象，相当于获取Driver
        self.s=session

    def login(self,body):        #接口调用成功后，断言rsp.status_code
        #2、使用会话对象S调用接口
        return  self.s.request(
            *JsonTool('./api_desc/api_desc.json').reader()['userLogin'],
            data=body)

if __name__ == '__main__':
    rsp=LoginApi().login({
        "username": "admin",
        "password": "Milor123",
        "verifycode": "2222"
    })
    print(rsp.status_code)
    print(rsp.text)
